package com.zb.mobile.network.controller;

import com.zb.entity.AccounLoginInfo;
import com.zb.mobile.NetworkOrderRecordSearchVo;
import com.zb.mobile.WithdrawMobileVo;
import com.zb.mobile.WithdrawRecordListSearchMobileVo;
import com.zb.mobile.network.service.ConNetworkMobileWithdrawService;
import com.zb.result.PageUtil;
import com.zb.result.Result;
import com.zb.utils.TokenNetworkUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * @Author WEN
 * @Date 2024/5/25 0025
 **/
@Api(tags = "服务商移动端提现类接口")
@RestController
@RequestMapping("/mobile/network")
public class NetworkMobileWithdrawController {
    @Resource
    private ConNetworkMobileWithdrawService conNetworkMobileWithdrawService;

    @ApiOperation("获取提现账户金额")
    @GetMapping("/getWithdrawMoney")
    public Result getWithdrawMoney(HttpServletRequest request) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success().data(PageUtil.row(conNetworkMobileWithdrawService.getWithdrawMoney(loginInfo)));
    }

    @ApiOperation("获取工单记录")
    @PostMapping("/getOrderRecord")
    public Result getWithdrawOrderRecord(HttpServletRequest request, @RequestBody NetworkOrderRecordSearchVo search) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success().data(conNetworkMobileWithdrawService.getMobileWithdrawOrderRecord(loginInfo, search));
    }

    @ApiOperation("获取工单记录详情")
    @GetMapping("/getWithdrawOrderRecordDetail/{workId}")
    public Result getWithdrawOrderRecordDetail(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        return Result.success().data(PageUtil.row(conNetworkMobileWithdrawService.getWithdrawOrderRecordDetail(workId)));
    }

    @ApiOperation("获取可提现工单列表")
    @PostMapping("/getWithdrawOrderList")
    public Result getWithdrawOrderList(HttpServletRequest request, @RequestBody NetworkOrderRecordSearchVo search) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success().data(conNetworkMobileWithdrawService.getMobileWithdrawOrderList(loginInfo, search));
    }

    @ApiOperation("保存申请提现")
    @PostMapping("/save")
    public Result save(HttpServletRequest request, @RequestBody @Valid WithdrawMobileVo withdrawMobileVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        conNetworkMobileWithdrawService.saveMobileWithdraw(loginInfo, withdrawMobileVo);
        return Result.success();
    }

    @ApiOperation("获取提现记录")
    @PostMapping("/getWithdrawRecordList")
    public Result getWithdrawRecordList(HttpServletRequest request, @RequestBody WithdrawRecordListSearchMobileVo search) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success().data(conNetworkMobileWithdrawService.getWithdrawRecordList(loginInfo, search));
    }

    @ApiOperation("获取提现记录详情")
    @GetMapping("/getWithdrawRecordDetail/{id}")
    public Result getWithdrawRecordDetail(@PathVariable @ApiParam(value = "提现ID", required = true) Long id) {
        return Result.success().data(PageUtil.row(conNetworkMobileWithdrawService.getWithdrawRecordDetail(id)));
    }

    @ApiOperation("根据提现单ID获取提现工单")
    @GetMapping("/getWithdrawOrderList/{id}")
    public Result getWithdrawOrderList(@PathVariable @ApiParam(value = "提现ID", required = true) Long id) {
        return Result.success().data(PageUtil.rows(conNetworkMobileWithdrawService.getWithdrawOrderList(id)));
    }




}
